package br.com.schs.sessionbeans;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import br.com.schs.entity.Departamento;

@Stateless
public class DepartamentoSessionBean {

	@PersistenceContext
	private EntityManager entityManager;
	
	@SuppressWarnings("unchecked")
	public List<Departamento> consultarTodosDepartamentos(){
		Query query = entityManager.createNamedQuery("Departamento.consultarTodosDepartamentos");
		try {
			return query.getResultList();
		} catch (NoResultException e) {
			return null;
		}
	}
	
}
